<%@include file="include_top.jspf"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>BidPirate - List Bids</title>
</head>
<body>
<script>
    function confirmAndDelete(description, id) {
        if (confirm("Delete \"" + description + "\" ?")) {
            window.location.href = "listBids_deleteBid.html?id=" + id;
        }
    }
	new Image().src="static/synchronising.gif";
</script>
<c:if test="${not userSession.loggedIn && not empty pager.pageResults}">
<p class="info">Log in with your eBay account to save your items.</p>
</c:if>
<table style="text-align: center;">
    <thead>
        <tr>
        	<th width="100"></th>
        	<th width="240">Description</th>
        	<th width="120">Price</th>
        	<th width="120">Bid</th>
        	<th width="120">Ends</th>
        	<th width="100">Status</th>
        	<th width="40"></th>
        	<th width="80"></th>
        </tr>
    </thead>
	<tbody>    
<c:forEach items="${pager.pageResults}" var="bid">
		<tr>
			<td><img src="${bid.item.imageUrl}" width="100"/></td>
			<td>
				<a href="${fn:replace(openItemUrl,'%ITEM_NUMBER%',bid.item.itemNumber)}" target="ebay" title="Open in eBay">${bid.item.description}</a>
			</td>
			<td>
				${bid.item.currency}<fmt:formatNumber pattern="#,##0.00" value="${bid.item.price}"/>
			</td>
			<td>
<c:if test="${not empty bid.maxBid}">			
				${bid.item.currency}<fmt:formatNumber pattern="#,##0.00" value="${bid.maxBid}"/>
</c:if>
<c:if test="${bid.item.buyItNow}">
				<i style="font-size: x-small;">Buy It <font color="red">Now</font></i>
</c:if>
			
			</td>
			<td><joda:format pattern="E dd MMM HH:mm z" dateTimeZone="${userSession.user.region.timeZone}" value="${bid.item.endTime}"/></td>
			<td>
				<i>${fn:toLowerCase(bid.status)}</i>
			</td>
			<td class="left">
<c:if test="${bid.updatable}">			
				<a href="listBids_updateItem.html?bidId=${bid.id}" title="Synchronise with eBay"><img src="static/synchronise.gif" onclick="this.src='static/synchronising.gif'"/></a>
</c:if>
<c:if test="${bid.status=='WON'}">
				<img src="static/won.gif"/> 
</c:if>	
<c:if test="${bid.status=='LOST'}">
				<img src="static/lost.gif"/> 
</c:if>	
			</td>
			<td>
<c:if test="${bid.updatable && not bid.item.buyItNow}">			
				<input type="button" value="Edit" class="fill" onclick="location.href='editBid.html?id=${bid.id}'"/>
</c:if>				
				<input type="button" value="Delete" class="fill" <c:if test="${bid.status=='BIDDING'}">disabled="disabled"</c:if> onclick="confirmAndDelete('<spring:message text="${bid.item.description}" htmlEscape="true" javaScriptEscape="true"/>','${bid.id}')"/>
			</td>
		</tr>
</c:forEach>
    </tbody>
</table>
<c:if test="${pager.show}">
<p align="center">${pager.html}</p>
</c:if>
</body>
</html>
